<template>
  <div>
    <el-container>
      <el-header v-show="show">
        <el-menu
          class="el-menu-demo"
          mode="horizontal"
          background-color="#545c64"
          text-color="#fff"
          :router="true"
        >
          <div>
            <h2>UNI-ADMIN</h2>
          </div>
          <el-menu-item index="/user">首页</el-menu-item>

          <el-menu-item index="/shop">商品</el-menu-item>
          <el-menu-item index="order">订单</el-menu-item>
          <el-menu-item index="VIP">会员</el-menu-item>
          <el-menu-item index="4">设置</el-menu-item>
          <el-submenu index="2">
            <template slot="title">admin</template>
            <el-menu-item index="2-1">修改</el-menu-item>
            <el-menu-item index="2-2" @click="removesss">退出</el-menu-item>
          </el-submenu>
        </el-menu>
      </el-header>
      <router-view></router-view>
    </el-container>
  </div>
</template>


<script>
export default {
  data() {
    return {
      show: true,
    };
  },
  watch: {
    $route: {
      handler(newval, oldval) {
        if (newval.path == "/login") {
          this.show = false;
        } else {
          this.show = true;
        }
      },
    },
  },
  methods: {
    removesss() {
      localStorage.removeItem("token");
      this.$router.push("/login");
    },
  },
};
</script>


<style lang="scss" scoped>
.el-menu-demo {
  display: flex;
  div {
    flex: 1;
    display: flex;
    align-items: center;
    h2 {
      color: white;
    }
  }
}
</style>
